<?php
require_once 'buildCurl.php';
$res = json_decode(file_get_contents('php://input'), true);

$session = $res['session'];
$url = "http://211.82.48.36/student/integratedQuery/scoreQuery/unpassedScores/callback";

$myCurl = new MyCurl($url, $session);
$result = $myCurl->getResult();
$httpCode = $myCurl->getHttpCode();

if ($httpCode != 200) {
    $arr = array('err' => 1);
    exit(json_encode($arr));
}

$content = json_decode($result, true);

$list0 = $content[0]['cjList'];
$list1 = $content[1]['cjList'];

$result_arr_0 = [];
$result_arr_1 = [];

foreach ($list0 as $value0) {
    $name = $value0['courseName']; //名字
    $gpa = $value0['credit']; //绩点
    $cate = $value0['courseAttributeName']; //类型
    $course = $value0['courseScore']; //分数
    $result_arr_0[] = array($name, $gpa, $cate, $course);
}


foreach ($list1 as $value0) {
    $name = $value0['courseName']; //名字
    $gpa = $value0['credit']; //绩点
    $cate = $value0['courseAttributeName']; //类型
    $course = $value0['courseScore']; //分数
    $result_arr_1[] = array($name, $gpa, $cate, $course);
}

$result_arr = array($result_arr_0, $result_arr_1);

$arr = array('err' => 0, 'result_arr' =>  $result_arr);
exit(json_encode($arr));
